<?php
/**
 * Created by PhpStorm.
 * User: zty
 * Date: 2018/10/23
 * Time: 21:11
 */

namespace app\admin\controller;
use think\Controller;
use think\Request;

class Order extends Controller
{

    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index($page =1 ,$pageSize = 10, $search =[])
    { $order = ['inputtime1'=>'desc'];
        $data = model('Common/Order')->getList($page,$pageSize,$search,$order);
        return ['code'=>0,'msg'=>'获取数据成功','data'=>$data];

    }


    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id)
    {
        $info = model('common/Order')->get_one($id);
//        $info['equ_name'] = "";
//        $info['equ_code'] = "";
//        $info['equ_address'] = "";
//        $info['equ_type'] = "";
        if(!empty($info['equ_id'])){
            $equipment = model('common/Equipment')->get_one($info['equ_id'],['name','code','address','type']);

            $info['equ_name'] = $equipment['name'];
            $info['equ_code'] = $equipment['code'];
            $info['equ_address'] = $equipment['address'];
            $info['equ_type'] = $equipment['type'];
        }
        if(!empty($info['accept'])) $info['accept_name'] = model('common/Staff')->get_one($info['accept'])['name'];
//

        return ['code'=>0,'msg'=>'获取数据成功','data'=>$info];
    }


}